<html>
<head><meta charset="utf-8"><title>Representing foreign system types · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html">Representing foreign system types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224194476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224194476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224194476">(Jan 27 2021 at 15:10)</a>:</h4>
<p>Hey, how would you go about representing a type that's native to a system/platform but has no primitive equivalent in Rust? For example if I had a function from a system that returns a 256 bit integer, or a 80 bit floating point number, how could I create an ABI compatible type for that?</p>



<a name="224194703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224194703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224194703">(Jan 27 2021 at 15:12)</a>:</h4>
<p>generally that needs compiler support, I think</p>



<a name="224194778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224194778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224194778">(Jan 27 2021 at 15:12)</a>:</h4>
<p>like <code>__m256</code> for example <a href="https://doc.rust-lang.org/core/arch/x86_64/struct.__m256.html">https://doc.rust-lang.org/core/arch/x86_64/struct.__m256.html</a></p>



<a name="224195499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224195499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224195499">(Jan 27 2021 at 15:16)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> So it wouldn't be enough for example to just have type that fits that layout like <code>pub struct __m256(f32, f32, f32, f32, f32, f32, f32, f32);</code> in my own lib code with <code>#[repr(C)]</code>?</p>



<a name="224195627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224195627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224195627">(Jan 27 2021 at 15:17)</a>:</h4>
<p>Depends on the specific platform ABI, but I believe the SIMD types are usually passed in SIMD registers, and normal structs aren't</p>



<a name="224195761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224195761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224195761">(Jan 27 2021 at 15:18)</a>:</h4>
<p>And x87 floats would be passed in x87 registers, but <code>[u8; 10]</code> or something similar won't</p>



<a name="224201029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224201029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224201029">(Jan 27 2021 at 15:52)</a>:</h4>
<p>Hmm, annoying, but not a deal breaker. For other reasons I'm using a fork of the compiler for this platform anyway, so just means more work. You wouldn't happen to know where the code to add the translation is? It seems to be abit all over the place in <code>stdarch</code>, it seems like there's a proc macro that handles it?</p>



<a name="224201440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224201440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224201440">(Jan 27 2021 at 15:55)</a>:</h4>
<p>For SIMD types there is <code>#[repr(simd)]</code>. There is nothing for x87 floats.</p>



<a name="224201632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224201632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224201632">(Jan 27 2021 at 15:56)</a>:</h4>
<p>The x87 floats is what I'm most interested in. <span aria-label="smiley" class="emoji emoji-1f603" role="img" title="smiley">:smiley:</span></p>



<a name="224202070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224202070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224202070">(Jan 27 2021 at 15:59)</a>:</h4>
<p>I think you'd probably need to make a new lang item for that following the other primitive types</p>



<a name="224203821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Representing%20foreign%20system%20types/near/224203821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Representing.20foreign.20system.20types.html#224203821">(Jan 27 2021 at 16:06)</a>:</h4>
<p>Alright, thanks for the info everyone!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>